package us.icitap.commandcenter.ui.supervisor;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;

import com.vaadin.data.util.BeanItemContainer;

import us.icitap.commandcenter.CommandCenterUI;
import us.icitap.commandcenter.business.ejb.persistence.Call;
import us.icitap.commandcenter.business.ejb.persistence.CallStatusEnum;
import us.icitap.commandcenter.ui.custom.CustColumnGenerator;
import us.icitap.commandcenter.ui.custom.CustTable;
import us.icitap.commandcenter.ui.shared.CallTable;
import us.icitap.dao.Expression;
import us.icitap.dao.Operator;
import us.icitap.utils.Result;

public class CallForSupervisorTable extends CallTable{


	
	public CallForSupervisorTable() {
		super("Totali i telefonatave per supervizorin me status TELEFONATE E RE:");
		this.addGeneratedColumn("relatedCallNr", CustColumnGenerator.relatedCallNumberColumnGenerator);
		
		this.setVisibleColumns(new Object[]{"relatedCallNr","caller", "address", "description", "callReason", "mainDispatcher", "recordDate", "recordUser" });
		this.setColumnHeaders(new String[]{"NR I TEL","TELEFONUESI", "ADRESA", "PERSHKRIMI", "ARSYEJA E TELEFONATES", "ZONA MBULIMIT", "DT. REGJ.", "OPERATORI"});
		this.addGeneratedColumn("mainDispatcher", CustColumnGenerator.dispatcherColumnGenerator);
		this.addGeneratedColumn("caller", CustColumnGenerator.callerColumnGenerator);
		this.addGeneratedColumn("callReason", CustColumnGenerator.callReasonColumnGenerator);

		this.setPageLength(4);
		this.setWidth("980px");
		this.setColumnWidth("relatedCallNr", 30);
		this.setColumnWidth("caller", 100);
		this.setColumnWidth("address", 200);
		this.setColumnWidth("description", 200);
		this.setColumnWidth("mainDispatcher", 150);
		this.setImmediate(true);
		
		this.setSelectable(true);

		this.addStyleName("red");
		this.initTable();
	}
	
	public void initTable(){

		Result<List<Call>> result = CommandCenterUI.appStatelessBean.getNewCallListForSupervisor(CommandCenterUI.getUser().getCommandCenter());
		
		
		if(result.isSucceeded()){
			this.addCallList(result.getObject());
		}
		else
			CommandCenterUI.LOG.logp(Level.SEVERE,"SupervisorVerticalLayout","initTable()", result.getMessage());

		this.updateTable();
	}
	

	
}
